package com.hx.jeeadminbase.db.jeedao;

import com.github.pagehelper.PageInfo;
import com.hx.jeeadminbase.db.utils.OraProcedure;
import org.apache.ibatis.session.SqlSession;
import com.hx.jeeadminbase.db.utils.Record;

import java.util.List;
import java.util.Map;

/**
 * @program: jeeadmin
 * @description: 数据库访问基类接口
 * @author: xxm
 * @create: 2019-11-04 15:42
 **/
public interface JeeBaseDao {

    public int insert(String sqlId, Object entity) throws Exception;
    public int update(String sqlId, Object entity) throws Exception;
    public int delete(String sqlId, Object entity) throws Exception;
    public <E> List<E> selectList(String id) throws Exception;
    public <E> List<E> selectList(String id, Object object) throws Exception;
    public <E> E selectOne(String id) throws Exception;
    public <E> E selectOne(String id, Object object) throws Exception;

    /**
     * 分页查询
     * @param sqlId
     * @param param
     * @param pageIndex
     * @param pageSize
     * @return
     */
    public PageInfo<?> selectPage(String sqlId, Object params, int pageIndex, int pageSize) throws Exception;

    /**
     * 通过MyBatis sqlMapper执行sql分页查询,带分页item配置
     * @param sqlId
     * @param params
     * @param pageIndex
     * @param pageSize
     * @param navigatePages
     * @return
     * @throws Exception
     */
    public PageInfo<?> selectPage(String sqlId, Object params, int pageIndex, int pageSize, int navigatePages) throws Exception;

    /**
     * 调用Oracle函数
     *
     * @param function
     * @return
     * @throws Exception
     */
    public Map<String, Object> callOraFunction(OraProcedure function) throws Exception;

    /**
     * 调用Oracle存储过程
     *
     * @param procedure
     * @return
     * @throws Exception
     */
    public Map<String, Object> callOraProcedure(OraProcedure procedure) throws Exception;

    /**
     * 通过 MyBatis sqlMapper执行sql查询
     */
    public List<Map<String, Object>> findBySql(String sql) throws Exception;

    /**
     * 通过 MyBatis sqlMapper执行sql多行查询
     *
     * @param sql
     * @return
     * @throws Exception
     */
    public List<Record> selectListBySql(String sql) throws Exception;

    /**
     * 通过 MyBatis sqlMapper执行sql多行查询,带参数
     *
     * @param sql
     * @param params
     * @return
     * @throws Exception
     */
    public List<Record> selectListBySql(String sql, Object... params) throws Exception;

    /**
     * 通过 MyBatis sqlMapper执行sql单一查询
     *
     * @param sql
     * @return
     * @throws Exception
     */
    public Record selectOneBySql(String sql) throws Exception;

    /**
     * 通过 MyBatis sqlMapper执行sql单一查询,带参数
     *
     * @param sql
     * @param params
     * @return
     * @throws Exception
     */
    public Record selectOneBySql(String sql, Object... params) throws Exception;

    /**
     * 通过MyBatis sqlMapper执行sql更新
     *
     * @param sql
     * @return
     */
    public boolean updateBySql(String sql) throws Exception;

    /**
     * 通过MyBatis sqlMapper执行sql更新,带参数
     *
     * @param sql
     * @param params
     * @return
     * @throws Exception
     */
    public boolean updateBySql(String sql, Object... params) throws Exception;

    /**
     * 通过MyBatis sqlMapper执行sql删除
     *
     * @param sql
     * @return
     */
    public boolean deleteBySql(String sql) throws Exception;

    /**
     * 通过MyBatis sqlMapper执行sql删除,带参数
     *
     * @param sql
     * @param params
     * @return
     * @throws Exception
     */
    public boolean deleteBySql(String sql, Object... params) throws Exception;

    /**
     * 通过MyBatis sqlMapper执行sql插入
     *
     * @param sql
     * @return
     */
    public boolean insertBySql(String sql) throws Exception;

    /**
     * 通过MyBatis sqlMapper执行sql插入,带参数
     *
     * @param sql
     * @param params
     * @return
     * @throws Exception
     */
    public boolean insertBySql(String sql, Object... params) throws Exception;

    /**
     * 获取Oracle序列值
     *
     * @param seqName
     * @return
     * @throws Exception
     */
    public Long getDBSequenceValue(String seqName) throws Exception;

    /**
     * 获取SqlSession 执行Mybatis原生方法
     * @return
     */
    public SqlSession getSession();
}
